import mongoose, { Schema } from 'mongoose';

const schema = new Schema(
  {
    name: { type: String, required: true },
    user_group: {
      type: Schema.Types.ObjectId,
      ref: 'Group',
      required: true,
    },
  },
  {
    id: false, // 为了输出格式保持统一，禁用id virtual getter
    toJSON: { virtuals: true },
    collection: 'reply_template_groups',
  },
);

schema.virtual('templates', {
  ref: 'ReplyTemplate',
  localField: '_id',
  foreignField: 'template_group',
});

export default mongoose.model('ReplyTemplateGroup', schema);
